<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>优秀员工</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="robots" content="noindex,nofollow" />
		<link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
		<link rel="stylesheet" href="__CSS__/common.css" media="all">
		<style>
			ul.layui-tab-title li::after {
			  display: none;
			}

			ul.layui-tab-title li a::after {
			  left: 20px !important;
			}
			.new-form .layui-form-checked span,.new-form .layui-form-checked:hover span {
				background-color: #fff!important;
			}
		</style>
	</head>

	<body class="page-body">
		<h2 class="comm-title">优秀员工</h2>
		<div class="layui-tab">
			<ul class="layui-tab-title page-tab-title">
				<li><a href="{:url('index')}">优秀员工列表</a></li>
				<li class="layui-this"><a href="javascript:;">新增</a></li>
			</ul>
		</div>
		<div class="tpcms-body-div page-main">
			<form class="layui-form new-form" id="admin">
				<div class="layui-form-item">
					<label class="layui-form-label">头像</label>
					<div class="layui-input-block">
						<div class="layui-upload">
							<button type="button" class="layui-btn" id="test1">上传图片</button>
							<div class="layui-upload-list" style="width: 50px;">
								<img class="layui-upload-img" id="demo1" style="width: 80px;">
								<input type="hidden" name="photo">
								<p id="demoText"></p>
							</div>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">名称</label>
					<div class="layui-input-block">
						<input type="text" name="name" lay-verify="required" placeholder="请输入名称" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">备注</label>
					<div class="layui-input-block">
						<input type="text" name="remark" lay-verify="required" placeholder="请输入备注" class="layui-input">
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label">星星数</label>
					<div class="layui-input-block">
						<input type="text" name="review" lay-verify="required" placeholder="请输入星星数" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">好评率</label>
					<div class="layui-input-block">
						<input type="text" name="favorable" lay-verify="required" placeholder="请输入好评率%" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">排序</label>
					<div class="layui-input-block">
						<input type="text" name="sort" lay-verify="required" placeholder="请输入排序" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">状态</label>
					<div class="layui-input-block">
						<input type="checkbox" checked="checked" name="status" lay-skin="switch" value="1" lay-filter="switchTest" lay-text="ON|OFF">
					</div>
				</div>
				<div class="layui-form-item" pane="">
				    <label class="layui-form-label">案例</label>
				    <div class="layui-input-block">
						{volist name='$anli' id='co' key='k'}
							<input type="checkbox" name="a_ids[]" value="{$co.id}"  lay-skin="primary" title="{$co.d_title}" >
						{/volist}
				    </div>
				  </div>
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">简介</label>
					<div class="layui-input-block">
						<textarea id="content" style="display: none;" class="layui-textarea"></textarea>
						<input type="hidden" name="content">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button type="button" class="layui-btn new-btn-style" lay-submit lay-filter="admin">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary default-btn">重置</button>
					</div>
				</div>

			</form>


			<script src="__PUBLIC__/layui/layui.js"></script>
			<script src="__PUBLIC__/jquery/jquery.min.js"></script>

			<script>
				layui.use(['layer', 'form', 'layedit', 'upload'], function() {
					var layer = layui.layer,
						$ = layui.jquery,
						form = layui.form;
					upload = layui.upload;
					var layedit = layui.layedit;


					layedit.set({
						uploadImage: {
							url: "{:url('Common/file_upload')}",
							type: 'post' //默认post
						}
					});

					 content = layedit.build('content'); //建立编辑器

					//普通图片上传
					var uploadInst = upload.render({
						elem: '#test1',
						url: "{:url('Common/file_upload')}" //改成您自己的上传接口

							,
						done: function(res) {
							//如果上传失败
							console.log(res)
							if (res.code == 0) {
								$("input[name='photo']").val(res.data.src)
								$('#demo1').attr('src', res.data.src);
							}
							//上传成功
						},

					});
					
					form.on('submit(admin)', function(data) {
						var con = layedit.getContent(content);
						$("input[name='content']").val(con)
						$.ajax({
							url: "{:url('add')}",
							data: $('#admin').serialize(),
							type: 'post',
							success: function(res) {
								if (res.code == 0) {
									layer.msg(res.message, {
										offset: '15px',
										icon: 1,
										time: 1000
									}, function() {
										window.location.href = "{:url('index')}";
									});
								} else {
									layer.msg(res.message, {
										offset: '15px',
										icon: 2,
										time: 1000
									});
								}
							}
						})
						return false;
					});
				});
			</script>
		</div>
	</body>

</html>
